from sqlalchemy import BIGINT, VARCHAR, DateTime, Integer, Column, SmallInteger
from sqlalchemy.dialects.mssql import TINYINT

from app import db
from sqlalchemy.sql import text


class BasicTextStyle(db.Model):
    __tablename__ = 'basic_text_style'

    id = db.Column(BIGINT, primary_key=True)
    company_id = db.Column(BIGINT, index=True, comment='公司')
    type = db.Column(TINYINT, nullable=False, index=True, server_default=text("'1'"), comment='1:sys 2:custom')
    font = db.Column(VARCHAR(255), comment='字体')
    bold = db.Column(TINYINT, nullable=False, server_default=text("'0'"), comment='是否加粗 1:是 0否')
    italic = db.Column(TINYINT, nullable=False, server_default=text("'0'"), comment='是否倾斜 1:是 0否')
    border_style = db.Column(TINYINT, nullable=False, server_default=text("'1'"))
    underline = db.Column(TINYINT, nullable=False, server_default=text("'0'"), comment='是否加下划线 1:是 0否')
    font_color = db.Column(VARCHAR(255), comment='字体颜色')
    # background_color = db.Column(VARCHAR(255), comment='字体背景颜色')
    shadow_color = db.Column(VARCHAR(255), comment='阴影颜色')
    shadow_size = db.Column(VARCHAR(255), comment='阴影大小')
    outline_colour = db.Column(VARCHAR(255), comment='描边颜色')
    outline = db.Column(VARCHAR(255), comment='描边宽度')
    status = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:正常 0:删除')
    created_by = db.Column(BIGINT, comment='创建人')
    updated_by = db.Column(BIGINT, comment='更新人')
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)


class AiStyleTemplate(db.Model):
    __tablename__ = 'ai_style_templates'

    id = db.Column(BIGINT, primary_key=True)
    company_id = db.Column(BIGINT, index=True, comment='公司')
    type = db.Column(TINYINT, nullable=False, index=True, server_default=text("'1'"), comment='1:sys 2:custom')
    name = db.Column(VARCHAR(255), comment='模板名称')
    status = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:正常 0:删除')
    created_by = db.Column(BIGINT, comment='创建人')
    updated_by = db.Column(BIGINT, comment='更新人')
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)


#
class AiTemplateImage(db.Model):
    __tablename__ = 'ai_template_images'

    id = db.Column(BIGINT, primary_key=True)
    template_id = db.Column(db.Integer, db.ForeignKey("ai_style_templates.id"), nullable=False)
    path = db.Column(VARCHAR(255), nullable=False, comment='文件')
    width = db.Column(VARCHAR(255), nullable=False, comment='width')
    height = db.Column(VARCHAR(255), nullable=False, comment='height')
    x = db.Column(VARCHAR(255), comment='位置:X')
    y = db.Column(VARCHAR(255), comment='位置:Y')
    start_time = db.Column(VARCHAR(255), comment='in')
    type_in = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:开始后 2:结束前')
    end_time = db.Column(VARCHAR(255), comment='out')
    type_out = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:开始后 2:结束前')
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)


class AiTemplateSubtitle(db.Model):
    __tablename__ = 'ai_template_subtitles'

    id = db.Column(BIGINT, primary_key=True)
    template_id = db.Column(db.Integer, db.ForeignKey("ai_style_templates.id"), nullable=False)
    style_id = db.Column(db.Integer, db.ForeignKey("basic_text_style.id"), nullable=False)
    align = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='对齐 1:向左 2居中 3向右')
    size = db.Column(VARCHAR(255), nullable=False, server_default=text("'10'"), comment='字号')
    x = db.Column(VARCHAR(255), comment='位置:X')
    y = db.Column(VARCHAR(255), comment='位置:Y')
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)


#
class AiTemplateTitle(db.Model):
    __tablename__ = 'ai_template_titles'

    id = db.Column(BIGINT, primary_key=True)
    template_id = db.Column(db.Integer, db.ForeignKey("ai_style_templates.id"), nullable=False)
    x = db.Column(VARCHAR(255), comment='位置:X')
    y = db.Column(VARCHAR(255), comment='位置:Y')
    style_id = db.Column(db.Integer, db.ForeignKey("basic_text_style.id"), nullable=False)
    align = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='对齐 1:向左 2居中 3向右')
    size = db.Column(VARCHAR(255), nullable=False, server_default=text("'10'"), comment='字号')
    start_time = db.Column(VARCHAR(255), comment='in')
    type_in = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:开始后 2:结束前')
    end_time = db.Column(VARCHAR(255), comment='out')
    type_out = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:开始后 2:结束前')
    is_ai = db.Column(TINYINT, nullable=False, server_default=text("'1'"), comment='1:auto 2:custom')
    text = db.Column(VARCHAR(255), comment='文本')
    created_at = db.Column(DateTime)
    updated_at = db.Column(DateTime)
